﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataContexts.Supplier;

/// <summary>
/// Summary description for SearchBookingBasePage
/// </summary>
public class SearchBookingBasePage : System.Web.UI.Page
{
    protected SupplierDataContext supplierContext = new SupplierDataContext();

    protected int CountryId
    {
        get { return Helper.QSIntValue("cid"); }
    }
    protected int RegionId
    {
        get { return Helper.QSIntValue("rid"); }
    }
    protected int LocationId
    {
        get { return Helper.QSIntValue("lid"); }
    }
    protected DateTime PickUpDate
    {
        get { return Helper.QSDateValue("pdt"); }
    }
    protected DateTime DropDate
    {
        get { return Helper.QSDateValue("ddt"); }
    }
    protected decimal PickUpTime
    {
        get { return Helper.QSDecimalValue("pt"); }
    }
    protected decimal DropTime
    {
        get { return Helper.QSDecimalValue("dt"); }
    }
    protected int AdultCapacity
    {
        get { return Helper.QSIntValue("acp"); }
    }
    protected int ChildrenCapacity
    {
        get { return Helper.QSIntValue("ccp"); }
    }
    protected int LuggageCapacity
    {
        get { return Helper.QSIntValue("lcp"); }
    }
    protected Enums.ACOptions ACOption
    {
        get { return (Enums.ACOptions)Helper.QSIntValue("acopt"); }
    }
    protected Enums.Transmissions Transmission
    {
        get { return (Enums.Transmissions)Helper.QSIntValue("tropt"); }
    }
    protected int SupplierVehicleId
    {
        get { return Helper.QSIntValue("svid"); }
    }
    protected int SupplierLocationVehicleId
    {
        get { return Helper.QSIntValue("slvid"); }
    }
    protected int SupplierId
    {
        get { return Helper.QSIntValue("sid"); }
    }
    protected bool AvailNavigator
    {
        get { return Helper.QSBoolValue("anv"); }
    }
    protected bool AvailNavWithFixPrice
    {
        get { return Helper.QSBoolValue("anvf"); }
    }
    protected bool AvailInsurance
    {
        get { return Helper.QSBoolValue("ains"); }
    }
    protected bool PayOnArrival
    {
        get { return Helper.QSBoolValue("poa"); }
    }
    public int PageSize
    {
        get { return Helper.QSIntValue("ps"); }
    }
    public int CurrentPageIndex
    {
        get { return (Helper.QSIntValue("cpi") == 0 ? 1 : Helper.QSIntValue("cpi")); }
    }
    protected override void OnLoad(EventArgs e)
    {
        if (!ValidRequest())
        {
            Response.Redirect("/default.aspx", true);
        }
        base.OnLoad(e);
    }

    protected bool ValidRequest()
    {
        if (PickUpDate == DateTime.MinValue ||
            CountryId == 0 ||
            RegionId == 0 ||
            LocationId == 0 ||
            DropDate == DateTime.MinValue)
            return false;
        return true;
    }
}
